package com.supinfo.food.services;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

import com.supinfo.food.dao.DaoFactory;
import com.supinfo.food.dao.MagasinDao;
import com.supinfo.food.entities.Magasin;

/**
 * Magasin Service
 * @author Keitaro
 */
@WebService(name="Magasin", serviceName="Magasin")
public class MagasinService {

	private MagasinDao dao = DaoFactory.getMagasinDao();
	
	@WebMethod(operationName="add")
	public void	add(@WebParam(name="magasin") Magasin magasin) {
		dao.persist(magasin);
	}
	
	@WebMethod(operationName="getAll")
	public Magasin[]	getAll() {
		return dao.getAll().toArray(new Magasin[1]);
	}
	
	@WebMethod(operationName="delete")
	public void	delete(Long id) {
		dao.remove(id);
	}
	
	@WebMethod(operationName="getCountries")
	public String[] getCountries() {
		return dao.getCountries().toArray(new String[1]);
	}
}
